import http from '@/utils/http'

const BASE_URL = '/system/socialAccount'

export interface SocialAccountResp {
  id: string
  userType: string
  userId: string
  source: string
  openId: string
  metadata: string
}

export interface SocialAccountDetailResp extends SocialAccountResp {
}

export interface SocialAccountQuery extends SortQuery {
  userType?: string
  userId?: string
  source?: string
  openId?: string
}

export interface SocialAccountPageQuery extends SocialAccountQuery, PageQuery {

}

/** @desc 查询社交账户列表 */
export function getPage(query: SocialAccountPageQuery) {
  return http.get<Page<SocialAccountResp[]>>(`${BASE_URL}/page`, query)
}

/** @desc 查询社交账户详情 */
export function getDetail(id: string) {
  return http.get<SocialAccountDetailResp>(`${BASE_URL}/detail/${id}`)
}

/** @desc 创建社交账户 */
export function create(data: any) {
  return http.post(`${BASE_URL}/create`, data)
}

/** @desc 修改社交账户 */
export function update(data: any, id: string) {
  return http.post(`${BASE_URL}/update/${id}`, data)
}

/** @desc 删除社交账户 */
export function remove(ids: string | Array<string>) {
  return http.post(`${BASE_URL}/delete/${ids}`)
}
